package com.ruanyun.util;


import cn.stylefeng.roses.core.util.ToolUtil;
import com.ruanyun.api.core.constant.JwtConstants;
import com.ruanyun.api.core.util.JwtTokenUtil;

import javax.servlet.http.HttpServletRequest;

public class TokenUtils {

	public String getUserId(HttpServletRequest request){
		//获取token中的userId
		String requestHeader = request.getHeader(JwtConstants.AUTH_HEADER);
		if(ToolUtil.isEmpty(requestHeader)){
			return "";
		}
		String authToken = requestHeader.substring(7);
		String userId = JwtTokenUtil.getUsernameFromToken(authToken);
		return userId;
	}

}
